package com.cloudsigns.factorymanager2.produce.activity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.MotionEvent;
import android.view.View;
import android.view.Window;

import com.bumptech.glide.Glide;
import com.cloudsigns.factorymanager2.R;
import com.cloudsigns.factorymanager2.produce.customview.PhotoView.PhotoView;
import com.cloudsigns.factorymanager2.produce.customview.PhotoView.PhotoViewAttacher;

public class AvatarImageShowerActivity extends Activity {
    private PhotoView head_shower;
    private String imageUrl;
    private PhotoViewAttacher mAttacher;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        this.requestWindowFeature(Window.FEATURE_NO_TITLE);//去掉标题栏
        setContentView(R.layout.layout_avatar_image_shower);

        head_shower = findViewById(R.id.head_shower);

        Intent intent = getIntent();
        imageUrl = intent.getStringExtra("imageUrl");

        if (!TextUtils.isEmpty(imageUrl)) {
            Glide.with(this).load(imageUrl).thumbnail(0.1f).error(R.mipmap.default_avatar).into(head_shower);
        }

        mAttacher = new PhotoViewAttacher(head_shower);
        mAttacher.setOnPhotoTapListener(new PhotoViewAttacher.OnPhotoTapListener() {
            @Override
            public void onPhotoTap(View view, float x, float y) {
                finish();
            }
        });
    }

    @Override
    public boolean onTouchEvent(MotionEvent event) {
        // TODO Auto-generated method stub
        finish();

        return false;
    }

    @Override
    protected void onDestroy() {
        // TODO Auto-generated method stub
        super.onDestroy();
        try {
            if (null != head_shower) {
                head_shower = null;
            }

            if (null != mAttacher) {
                mAttacher = null;
            }
        } catch (Exception e) {
            return;
        }
    }

    @Override
    protected void onResume() {
        // TODO Auto-generated method stub
        super.onResume();
    }
}
